package io.gitee.yth.design.pattern.test.core.pattern.creational.singleton;

/**
 * 5) 懒汉式（线程安全，同步代码块）
 * <p>
 * 仍然有线程安全问题，可能生成多个对象实例
 * <p>
 * 结论：不能使用
 *
 * @author yth
 * @since 2023-04-16-20:42
 */
public class Singleton5 {

    private static Singleton5 instance;

    public static Singleton5 getInstance() {
        if (instance == null) {
            synchronized (Singleton5.class) {
                instance = new Singleton5();
            }
        }
        return instance;
    }


    private Singleton5() {
    }
}
